package com.baibei.shiyi.scheduler.jobhandler;

import com.baibei.shiyi.common.tool.api.ApiResult;
import com.baibei.shiyi.product.feign.bean.dto.SpuDto;
import com.baibei.shiyi.product.feign.bean.vo.BaseProductSkuVo;
import com.baibei.shiyi.product.feign.client.admin.IAdmProductFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * 任务Handler示例（Bean模式）
 *
 * 开发步骤：
 * 1、继承"IJobHandler"：“com.xxl.job.core.handler.IJobHandler”；
 * 2、注册到Spring容器：添加“@Component”注解，被Spring容器扫描为Bean实例；
 * 3、注册到执行器工厂：添加“@JobHandler(value="自定义jobhandler名称")”注解，注解value值对应的是调度中心新建任务的JobHandler属性的值。
 * 4、执行日志：需要通过 "XxlJobLogger.log" 打印执行日志；
 *
 * @author xuxueli 2015-12-19 19:43:36
 */
@JobHandler(value="productJobHandler")
@Component
public class ProductJobHandler extends IJobHandler {

	@Autowired
	private IAdmProductFeign admProductFeign;

	@Override
	public ReturnT<String> execute(String param) throws Exception {
		XxlJobLogger.log("商品定时任务dto");
		SpuDto spuDto = new SpuDto();
		spuDto.setSpuNo("111");
		ApiResult<List<BaseProductSkuVo>> productSkuList = admProductFeign.getProductSkuList(spuDto);
		System.out.println(productSkuList);
		return SUCCESS;
	}

}
